import Ajax from "./ajax";
import appconsts from "./appconst";

const TinymceInit = {
  language_url: '/tinymce/langs/zh_CN.js',
  language: 'zh_CN',
  skin_url: '/tinymce/skins/ui/oxide', //public目录下
  height: 400,
  menubar: false,
  content_css: '/style/tinymce.css',
  plugins: [
    'advlist autolink lists link image charmap print preview anchor',
    'searchreplace visualblocks code fullscreen',
    'insertdatetime media table paste code help wordcount'
  ],
  toolbar1:
    'code | image link | undo redo | fontselect fontsizeselect formatselect | bold italic underline strikethrough',
  toolbar2:
    'forecolor backcolor | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | removeformat | help',
  toolbar_drawer: 'sliding',
  //images_upload_url: appconsts.remoteServiceBaseUrl + '/Picture/UploadPicture',
  //images_upload_base_path: appconsts.remoteServiceBaseUrl,
  images_upload_handler: function (blobInfo, success, failure) {
    let formData = new FormData();
    formData.append('file', blobInfo.blob(), blobInfo.filename());
    Ajax.post("/Picture/UploadPicture",formData).then((res)=>{
      console.log(res);
      success(appconsts.remoteServiceBaseUrl + (res as any).data.result.url);
    }).catch(()=>{
      failure("图片上传失败");
    })
  }
};
export default TinymceInit